<template>
  <div class="wisdomContainer">
    <!-- 头部 -->
    <van-nav-bar
      title="搜索"
      left-arrow
      @click-left="onClickLeft"
      class="navheadrt"
    >
    </van-nav-bar>
    <div class="bookIndexContainer">
      <div class="searchCont f">
        <input
          type="text"
          placeholder="请输入关键字"
          class="searchInput fl"
          v-model="keywords"
        />
        <div class="right f fc" @click="getbookContent1">
          <van-icon name="search" class="searchicon" />
          搜索
        </div>
      </div>
      <!-- 内容 -->
      <div class="content">
        <p class="title">共找到{{ searchList.length }}个结果</p>
        <ul class="searchUl">
          <li class="searchli" v-for="(item, index) in searchList" :key="index" @click="toContent(item.ID)">
            {{ item.Content }}
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import { getbookContent } from "@/api/api";
var projectId = localStorage.getItem("projectid");

export default {
  data() {
    return {
      tabIndex: 0,
      tabNav: [
        { id: 0, name: "浏览记录" },
        { id: 2, name: "项目管理" },
        { id: 3, name: "工艺工法" },
      ],
      keywords: "",
      documnetid: "",
      searchList: [],
    };
  },
  mounted() {
    this.documnetid = this.$route.query.id;
    this.keywords = this.$route.query.keywords;
    this.getbookContent1();
  },
  methods: {
    toBook() {
      this.$router.push({ path: "/bookIndex" });
    },
    toContent(sid){
  this.$router.push({ path: "/bookContent",query:{sid} });
    },
    onClickLeft() {
      this.$router.go(-1);
    },
    tabTap(index) {
      this.tabIndex = index;
    },
    getbookContent1() {
      this.Request(
        getbookContent({
          documentid: this.documnetid,
          ProjectID: projectId,
          keywords: this.keywords,
        })
      ).then((res) => {
        if (res.StatusCode == "200") {
          this.searchList = res.Detiel;
        } else {
          this.$message({
            type: "error",
            message: res.message,
            center: "true",
          });
        }
      });
    },
  },
};
</script>
<style lang="stylus" scoped>
.wisdomContainer {
  width: 100%;
  height: 100%;

  .navheadrt {
    /deep/ .van-nav-bar__title, /deep/.van-icon {
      color: #fff !important;
    }
  }

  .van-nav-bar {
    width: 100%;
    height: 88px;
    // border-bottom: 1px solid #E5E5E5;
    background: #699fff;

    .van-nav-bar__title, .van-nav-bar__left, .van-nav-bar__right {
      color: #fff;
      height: 87px;
      line-height: 87px;
      font-size: $font-size-title;
      z-index: 10000;
      border: none;
    }

    .van-icon-arrow-left {
      color: #fff;
      font-size: $font-size-title;
    }

    .van-nav-bar__text {
      color: #fff;
      font-size: $font-size-title;
    }
  }

  .bookIndexContainer {
    width: 100%;
    height: calc(100% - 88px);
    padding: 30px 40px;
    box-sizing: border-box;
    overflow: hidden;

    .searchCont {
      width: 100%;
      margin-bottom: 60px;

      .searchInput {
        height: 56px;
        background: #FFFFFF;
        box-shadow: 0px 5px 16px 0px rgba(70, 70, 70, 0.26);
        border-radius: 5px;
        padding-left: 30px;
        box-sizing: border-box;
      }

      .right {
        width: 120px;
        height: 56px;
        margin-left: 15px;
        background: #699FFF;
        box-shadow: 0px 5px 16px 0px rgba(70, 70, 70, 0.26);
        border-radius: 5px;
        font-size: 24px;
        font-family: Microsoft YaHei;
        font-weight: 300;
        color: #FFFFFF;

        .searchicon {
          font-size: 32px;
          margin-right: 15px;
        }
      }
    }

    .content {
      width: 100%;
      height: 100%;

      .title {
        font-size: 32px;
        color: #699FFF;
        text-align: center;
        margin-bottom: 60px;
      }

      .searchUl {
        width: 100%;

        .searchli {
          width: 100%;
          font-size: 28px;
          line-height: 32px;
          border-bottom: 1px solid #ccc;
          padding-bottom: 10px;
          margin-bottom: 30px;
        }
      }
    }
  }
}
</style>